package com.principle.ocp;

import java.text.NumberFormat;
import java.util.List;

/**
 * @author yangguanzan
 * @date 3/10/22
 * @description
 */
public class BookStore {

    private List<IBook> bookList;
    public void setBookList(List<IBook> bookList) {
        this.bookList = bookList;
    }

    public void sellAllBook() {
        System.out.println("——————书店卖出去的书如下——————");
        if(null!=bookList&&!bookList.isEmpty()){
            NumberFormat format = NumberFormat.getCurrencyInstance();
            format.setMaximumFractionDigits(2);
            for (IBook book:bookList) {
                System.out.println("书名：" +book.getName()
                    +"，作者：" +book.getAuthor()
                    +"，价格："+format.format(book.getPrice()/100.0)
                    +"元。");
            }
        }

    }
}
